import requests

"""
参数无论get还是post都用param传递
参数无需用unicode编码
不需要请求对象定制
"""
base_url = 'https://www.baidu.com/s'
headers = {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    # 'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    'Cookie': 'BIDUPSID=8AC47C91EB24CEF54D60954251023E56; PSTM=1662460286; BAIDUID=1C81DFCBB13256AD62B7F7C55C088BF0:FG=1; BD_UPN=12314753; BDUSS=l1VjEyUm1CMjkyODFHVjktak9SR35rVVQ3RUhTVmxVMUR2clh4ODhsOHo2WTltRVFBQUFBJCQAAAAAAQAAAAEAAABFqE5lVm9rdGEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADNcaGYzXGhmNG; BDUSS_BFESS=l1VjEyUm1CMjkyODFHVjktak9SR35rVVQ3RUhTVmxVMUR2clh4ODhsOHo2WTltRVFBQUFBJCQAAAAAAQAAAAEAAABFqE5lVm9rdGEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADNcaGYzXGhmNG; H_PS_PSSID=60236_60326_60334_60297_60345; H_WISE_SIDS=60236_60326_60334_60297_60345; BA_HECTOR=2ka1248h8g2k2g800485ak0l95btpl1j6oell1v; ZFY=QA1Cl0N7KouaHe:A8lZEMeUihNzxy5WzBRcUKjovdk5Q:C; BAIDUID_BFESS=1C81DFCBB13256AD62B7F7C55C088BF0:FG=1; B64_BOT=1; channel=lenovo.ilive.cn; H_WISE_SIDS_BFESS=60236_60326_60334_60297_60345; baikeVisitId=e8285057-e943-4fb4-98ed-a17986ab9d8f; ab_sr=1.0.1_YjA2OTQ5OTkxNzQ2ZDkwYjA3MjA2NDNmNzk3M2I5YTM5NjA4NTA5Zjc2YWYyNWZiMzAyMDI5YTc0MmI2ODhiMDAzMGZmMmVlNTNlOTAxNjQxZjNmMzUyYjBjNjU0MjQ0MzBhZmU2NGUwODExNDM5MWJhZmZhNTQyZGY3ZTMyYjlmZmQ0MGViZDMzYWRiN2EwMTQxZTkyNTQwODk2ODc5MmQ1OWExMWYyYTZhMjY0ZGFhZGY1NGRiYWJkZjMxZmM2; COOKIE_SESSION=2970_2_2_3_13_4_1_0_2_2_0_0_3017_22_50_0_1718432933_1718369678_1718432883%7C9%23430565_29_1718369652%7C9; BDRCVFR[TVogQ1G2T-s]=-kY6jVJCv-DpykGIhR8mv3; delPer=0; BD_CK_SAM=1; PSINO=2; sugstore=0; H_PS_645EC=eb54TZYCjTZVa0cDqyUhHTi3pnsoUe6cYGdVM5aJg07UO92CISyCMooZcNs; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598',
    'Host': 'www.baidu.com',
    'sec-ch-ua': '"Chromium";v="9", "Not?A_Brand";v="8"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'Sec-Fetch-Dest': 'document',
    'Sec-Fetch-Mode': 'navigate',
    'Sec-Fetch-Site': 'none',
    'Sec-Fetch-User': '?1',
    'Upgrade-Insecure-Requests': '1',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.3.5211 SLBChan/105',
}
data = {
    "wd": "北京"
}
resp = requests.get(url=base_url, headers=headers, params=data)
resp.encoding = 'utf-8'
print(resp.text)
